/**
 * 
 */
package com.webserver;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author Lituo Wang
 */
public class WebServer {

	public void serverStart(int port) {
		try {
			ServerSocket serverSocket = new ServerSocket(8000);
			while (true) {
				Socket scoket = serverSocket.accept();
				new Processor(scoket).start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int port = 80;
		if (args.length == 1)
			port = Integer.parseInt(args[1]);
		new WebServer().serverStart(port);
	}
}
